function APPFun() {
	return {
		ajax: function(cmd, parm, successCallback, errorCallback, IP, data) {
			uni.onNetworkStatusChange(function(res) {
				if (!res.isConnected) {
					uni.showToast({
						title: '网络连接不可用！',
						icon: 'none'
					});
				}
				return false
			});
			var url = ''
			if (IP) {
				if (data == 1) {
					url = IP + '?cmdname=' + cmd;
				} else if (data == 2) {
					url = IP + '?cmd=' + cmd;
				} else {
					url = IP
				}
			} else {
				url = uni.getStorageSync('IPAgreement') + uni.getStorageSync('serverIP') +
					'/Frame/SqlData?cmdname=' + cmd;
			}


			if (uni.getStorageSync('UserInfo')) {
				if (!parm.hasOwnProperty("P_UserID")) {
					parm.P_UserID = uni.getStorageSync('UserInfo').UserID;
				}
				if (!parm.hasOwnProperty("P_UserName")) {
					parm.P_UserName = uni.getStorageSync('UserInfo').UserName;
				}
				if (!parm.hasOwnProperty("P_UserCode")) {
					parm.P_UserCode = uni.getStorageSync('UserInfo').UserCode;
				}

			}

			uni.request({
				url: url,
				data: parm,
				method: 'POST',
				timeout: 10000,
				header: {
					'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
				},
				success: (ret) => {
					// console.log(ret)
					if (ret) {
						if (ret.data.status == 200) {
							if (successCallback) successCallback(ret.data.data);
						} else {
							uni.showToast({
								title: cmd + '\n' + uni.getStorageSync('serverIP') + '\n' +
									'错误代码1:' +
									'\n' + JSON.stringify(ret),
								icon: 'none'
							});
							if (errorCallback) errorCallback(ret.data);
						}
					} else {
						if (errorCallback) {
							errorCallback(err);
						} else {
							console.log(JSON.stringify(err))
						}
					}
				}
			});
		}
	}
}

export default APPFun();